<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Hardware Abstraction Layer (HAL)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="logo.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Hardware Abstraction Layer (HAL)</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__group__hal__spi.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#groups">API Reference</a> &#124;
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Macros</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">SPI (Serial Peripheral Interface)<div class="ingroups"><a class="el" href="group__group__hal.html">HAL Drivers</a></div></div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<p >High level interface for interacting with the Serial Peripheral Interface (SPI). </p>
<p >The SPI protocol is a synchronous serial interface protocol. Devices operate in either master or slave mode. The master initiates the data transfer.</p>
<p >Motorola SPI modes 0, 1, 2, and 3 are supported, with either MSB or LSB first. The operating mode and data frame size can be configured via <a class="el" href="group__group__hal__spi.html#structcyhal__spi__cfg__t">cyhal_spi_cfg_t</a>.</p>
<h1><a class="anchor" id="section_spi_features"></a>
Features</h1>
<ul>
<li>Supports master and slave functionality.</li>
<li>Supports Motorola modes - 0, 1, 2 and 3 - <a class="el" href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">cyhal_spi_mode_t</a></li>
<li>MSb or LSb first shift direction - <a class="el" href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">cyhal_spi_mode_t</a></li>
<li>Master supports up to four slave select lines</li>
<li>Supports data frame size of 8 or 16 bits</li>
<li>Configurable interrupt and callback assignment on SPI events: Data transfer to FIFO complete, Transfer complete and Transmission error - <a class="el" href="group__group__hal__spi.html#gae8f0cf0233d0225a80815f8282d87b85">cyhal_spi_event_t</a></li>
<li>Supports changing baud rate of the transaction in run time.</li>
<li>Provides functions to send/receive a single byte or block of data.</li>
</ul>
<h1><a class="anchor" id="section_spi_quickstart"></a>
Quick Start</h1>
<p >Initialise a SPI master or slave interface using <a class="el" href="group__group__hal__spi.html#ga20c9cdb5b051ff8b68cf313fc19b550d">cyhal_spi_init()</a> and provide the SPI pins (<b>mosi</b>, <b>miso</b>, <b>sclk</b>, <b>ssel</b>), number of bits per frame (<b>data_bits</b>) and SPI Motorola <b>mode</b>. The data rate can be set using <a class="el" href="group__group__hal__spi.html#ga536ac25a0556330a35651e32b5c180cb">cyhal_spi_set_frequency()</a>. <br  />
 See <a class="el" href="group__group__hal__spi.html#section_spi_snippets">Code snippets</a> for code snippets to send or receive the data.</p>
<h1><a class="anchor" id="section_spi_snippets"></a>
Code snippets</h1>
<h2><a class="anchor" id="subsection_spi_snippet_1"></a>
Snippet 1: SPI Master - Single byte transfer operation (Read and Write)</h2>
<p >The following code snippet initializes an SPI Master interface using the <a class="el" href="group__group__hal__spi.html#ga20c9cdb5b051ff8b68cf313fc19b550d">cyhal_spi_init()</a>. The data rate of transfer is set using <a class="el" href="group__group__hal__spi.html#ga536ac25a0556330a35651e32b5c180cb">cyhal_spi_set_frequency()</a>. The code snippet shows how to transfer a single byte of data using <a class="el" href="group__group__hal__spi.html#ga24b88b94f4869a34a98a54fc0edf9e53">cyhal_spi_send()</a> and <a class="el" href="group__group__hal__spi.html#gad9e6f6399f3096426b718d58e813b0d1">cyhal_spi_recv()</a>. </p><div class="fragment"><div class="line">    <a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>   rslt;</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> mSPI;</div>
<div class="line">    uint32_t    spi_master_frequency = 1000000;</div>
<div class="line">    uint32_t    transmit_data        = 0x01;</div>
<div class="line">    uint32_t    receive_data;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Configuring the  SPI master:  Specify the SPI interface pins, frame size, SPI Motorola mode</span></div>
<div class="line">    <span class="comment">// and master mode</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__spi.html#ga20c9cdb5b051ff8b68cf313fc19b550d">cyhal_spi_init</a>(&amp;mSPI, CYBSP_SPI_MOSI, CYBSP_SPI_MISO, CYBSP_SPI_CLK, CYBSP_SPI_CS, NULL,</div>
<div class="line">                          8, <a class="code hl_enumvalue" href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51a8109c5d0edd4c10a68d82e98bd76de8a">CYHAL_SPI_MODE_00_MSB</a>, <span class="keyword">false</span>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Set the data rate to 1 Mbps</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__spi.html#ga536ac25a0556330a35651e32b5c180cb">cyhal_spi_set_frequency</a>(&amp;mSPI, spi_master_frequency);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Transfer one byte of data to the slave.</span></div>
<div class="line">    <span class="keywordflow">if</span> (<a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> == <a class="code hl_function" href="group__group__hal__spi.html#ga24b88b94f4869a34a98a54fc0edf9e53">cyhal_spi_send</a>(&amp;mSPI, transmit_data))</div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Receives one byte of data from the slave by transmiting a dummy byte 0xFF.</span></div>
<div class="line">        <span class="keywordflow">if</span> (<a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> == <a class="code hl_function" href="group__group__hal__spi.html#gad9e6f6399f3096426b718d58e813b0d1">cyhal_spi_recv</a>(&amp;mSPI, &amp;receive_data))</div>
<div class="line">        {</div>
<div class="line">            <span class="comment">// Transfer Complete and successful</span></div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="ttc" id="agroup__group__hal__impl__hw__types_html_structcyhal__spi__t"><div class="ttname"><a href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a></div><div class="ttdoc">SPI object.</div><div class="ttdef"><b>Definition:</b> cyhal_hw_types.h:1387</div></div>
<div class="ttc" id="agroup__group__hal__spi_html_ga20c9cdb5b051ff8b68cf313fc19b550d"><div class="ttname"><a href="group__group__hal__spi.html#ga20c9cdb5b051ff8b68cf313fc19b550d">cyhal_spi_init</a></div><div class="ttdeci">cy_rslt_t cyhal_spi_init(cyhal_spi_t *obj, cyhal_gpio_t mosi, cyhal_gpio_t miso, cyhal_gpio_t sclk, cyhal_gpio_t ssel, const cyhal_clock_t *clk, uint8_t bits, cyhal_spi_mode_t mode, bool is_slave)</div><div class="ttdoc">Initialize the SPI peripheral.</div></div>
<div class="ttc" id="agroup__group__hal__spi_html_ga24b88b94f4869a34a98a54fc0edf9e53"><div class="ttname"><a href="group__group__hal__spi.html#ga24b88b94f4869a34a98a54fc0edf9e53">cyhal_spi_send</a></div><div class="ttdeci">cy_rslt_t cyhal_spi_send(cyhal_spi_t *obj, uint32_t value)</div><div class="ttdoc">Synchronously send a byte out.</div></div>
<div class="ttc" id="agroup__group__hal__spi_html_ga536ac25a0556330a35651e32b5c180cb"><div class="ttname"><a href="group__group__hal__spi.html#ga536ac25a0556330a35651e32b5c180cb">cyhal_spi_set_frequency</a></div><div class="ttdeci">cy_rslt_t cyhal_spi_set_frequency(cyhal_spi_t *obj, uint32_t hz)</div><div class="ttdoc">Set the SPI baud rate.</div></div>
<div class="ttc" id="agroup__group__hal__spi_html_gad9e6f6399f3096426b718d58e813b0d1"><div class="ttname"><a href="group__group__hal__spi.html#gad9e6f6399f3096426b718d58e813b0d1">cyhal_spi_recv</a></div><div class="ttdeci">cy_rslt_t cyhal_spi_recv(cyhal_spi_t *obj, uint32_t *value)</div><div class="ttdoc">Synchronously get a received value out of the SPI receive buffer.</div></div>
<div class="ttc" id="agroup__group__hal__spi_html_ggaf56d895e50b0cf0e858a1ff221c58d51a8109c5d0edd4c10a68d82e98bd76de8a"><div class="ttname"><a href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51a8109c5d0edd4c10a68d82e98bd76de8a">CYHAL_SPI_MODE_00_MSB</a></div><div class="ttdeci">@ CYHAL_SPI_MODE_00_MSB</div><div class="ttdoc">Standard motorola SPI CPOL=0, CPHA=0 with MSB first operation.</div><div class="ttdef"><b>Definition:</b> cyhal_spi.h:188</div></div>
<div class="ttc" id="agroup__group__result_html_gaca79700fcc701534ce61778a9bcf57d1"><div class="ttname"><a href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a></div><div class="ttdeci">uint32_t cy_rslt_t</div><div class="ttdoc">Provides the result of an operation as a structured bitfield.</div><div class="ttdef"><b>Definition:</b> cy_result.h:438</div></div>
<div class="ttc" id="agroup__group__result_html_gaf58fac450d9fff4472f03ad68f6e546e"><div class="ttname"><a href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a></div><div class="ttdeci">#define CY_RSLT_SUCCESS</div><div class="ttdoc">cy_rslt_t return value indicating success</div><div class="ttdef"><b>Definition:</b> cy_result.h:465</div></div>
</div><!-- fragment --><h2><a class="anchor" id="subsection_spi_snippet_2"></a>
Snippet 2: SPI Slave - Single byte transfer operation (Read and Write)</h2>
<p >The following code snippet initializes an SPI Slave interface using the <a class="el" href="group__group__hal__spi.html#ga20c9cdb5b051ff8b68cf313fc19b550d">cyhal_spi_init()</a>. The data rate of transfer is set using <a class="el" href="group__group__hal__spi.html#ga536ac25a0556330a35651e32b5c180cb">cyhal_spi_set_frequency</a>. The code snippet shows how to transfer a single byte of data using <a class="el" href="group__group__hal__spi.html#ga24b88b94f4869a34a98a54fc0edf9e53">cyhal_spi_send()</a> and <a class="el" href="group__group__hal__spi.html#gad9e6f6399f3096426b718d58e813b0d1">cyhal_spi_recv</a>. </p><div class="fragment"><div class="line">    <a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>   rslt;</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> sSPI;</div>
<div class="line">    uint32_t    spi_slave_frequency = 1000000;</div>
<div class="line">    uint32_t    transmit_data       = 1;</div>
<div class="line">    uint32_t    receive_data;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Configuring the  SPI slave:  Specify the SPI interface pins, frame size, SPI Motorola mode</span></div>
<div class="line">    <span class="comment">// and slave mode</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__spi.html#ga20c9cdb5b051ff8b68cf313fc19b550d">cyhal_spi_init</a>(&amp;sSPI, CYBSP_SPI_MOSI, CYBSP_SPI_MISO, CYBSP_SPI_CLK, CYBSP_SPI_CS, NULL,</div>
<div class="line">                          8, <a class="code hl_enumvalue" href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51a8109c5d0edd4c10a68d82e98bd76de8a">CYHAL_SPI_MODE_00_MSB</a>, <span class="keyword">true</span>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Set the data rate to 1 Mbps</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__spi.html#ga536ac25a0556330a35651e32b5c180cb">cyhal_spi_set_frequency</a>(&amp;sSPI, spi_slave_frequency);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Place a byte in the TX FIFO to be read by the master</span></div>
<div class="line">    <span class="keywordflow">if</span> (<a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> == <a class="code hl_function" href="group__group__hal__spi.html#ga24b88b94f4869a34a98a54fc0edf9e53">cyhal_spi_send</a>(&amp;sSPI, transmit_data))</div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Get a received value out of the SPI receive buffer. This API Blocks until a value is</span></div>
<div class="line">        <span class="comment">// available</span></div>
<div class="line">        <span class="keywordflow">if</span> (<a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> == <a class="code hl_function" href="group__group__hal__spi.html#gad9e6f6399f3096426b718d58e813b0d1">cyhal_spi_recv</a>(&amp;sSPI, &amp;receive_data))</div>
<div class="line">        {</div>
<div class="line">            <span class="comment">// Transfer successful</span></div>
<div class="line">        }</div>
<div class="line">    }</div>
</div><!-- fragment --><h2><a class="anchor" id="subsection_spi_snippet_3"></a>
Snippet 3: SPI Block Data transfer</h2>
<p >The following snippet sends and receives an array of data in a single SPI transaction using <a class="el" href="group__group__hal__spi.html#gad21547fa4048c45f15308c0b1ff62c1f">cyhal_spi_transfer()</a>. The example uses SPI master to transmit 5 bytes of data and receive 5 bytes of data in a single transaction. </p><div class="fragment"><div class="line">    <a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>   rslt;</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> mSPI;</div>
<div class="line">    uint32_t    spi_frequency    = 1000000;</div>
<div class="line">    uint8_t     transmit_data[5] = { 0x1, 0x2, 0x3, 0x4, 0x5 };</div>
<div class="line">    uint8_t     receive_data[5];</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// BSP-1637 workaround</span></div>
<div class="line">    memset(&amp;mSPI, 0, <span class="keyword">sizeof</span>(mSPI));</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Configuring the  SPI interface:  Specify the SPI interface pins, frame size, SPI Motorola</span></div>
<div class="line">    <span class="comment">// mode and master/slave mode</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__spi.html#ga20c9cdb5b051ff8b68cf313fc19b550d">cyhal_spi_init</a>(&amp;mSPI, CYBSP_SPI_MOSI, CYBSP_SPI_MISO, CYBSP_SPI_CLK, CYBSP_SPI_CS, NULL,</div>
<div class="line">                          8, <a class="code hl_enumvalue" href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51a8109c5d0edd4c10a68d82e98bd76de8a">CYHAL_SPI_MODE_00_MSB</a>, <span class="keyword">false</span>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Set the data rate to 1 Mbps</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__spi.html#ga536ac25a0556330a35651e32b5c180cb">cyhal_spi_set_frequency</a>(&amp;mSPI, spi_frequency);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Master: Starts a data transfer. Slave: Prepares the slave for data transfer. It is a blocking</span></div>
<div class="line">    <span class="comment">// function</span></div>
<div class="line">    <span class="keywordflow">if</span> (<a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> == <a class="code hl_function" href="group__group__hal__spi.html#gad21547fa4048c45f15308c0b1ff62c1f">cyhal_spi_transfer</a>(&amp;mSPI, transmit_data, 5u, receive_data, 5u, 0xFF))</div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Transfer Complete</span></div>
<div class="line">    }</div>
<div class="ttc" id="agroup__group__hal__spi_html_gad21547fa4048c45f15308c0b1ff62c1f"><div class="ttname"><a href="group__group__hal__spi.html#gad21547fa4048c45f15308c0b1ff62c1f">cyhal_spi_transfer</a></div><div class="ttdeci">cy_rslt_t cyhal_spi_transfer(cyhal_spi_t *obj, const uint8_t *tx, size_t tx_length, uint8_t *rx, size_t rx_length, uint8_t write_fill)</div><div class="ttdoc">Synchronously Write a block out and receive a value.</div></div>
</div><!-- fragment --><h2><a class="anchor" id="subsection_spi_snippet_4"></a>
Snippet 4: Interrupts on SPI events</h2>
<p >SPI interrupt events ( <a class="el" href="group__group__hal__spi.html#gae8f0cf0233d0225a80815f8282d87b85">cyhal_spi_event_t</a>) can be mapped to an interrupt and assigned to a callback function. The callback function needs to be first registered and then the event needs to be enabled. The following snippet initialises a SPI master to perform a block transfer using <a class="el" href="group__group__hal__spi.html#ga3cbcb44263ba6af2668f8847b8c90210">cyhal_spi_transfer_async()</a>. This is a non-blocking function. A callback function is registered using <a class="el" href="group__group__hal__spi.html#ga5efa8d542f1ab5307d7896a249581a6a">cyhal_spi_register_callback</a> to notify whenever the SPI transfer is complete. </p><div class="fragment"><div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> spi_interrupt_callback(<span class="keywordtype">void</span>* arg, <a class="code hl_enumeration" href="group__group__hal__spi.html#gae8f0cf0233d0225a80815f8282d87b85">cyhal_spi_event_t</a> event)</div>
<div class="line">{</div>
<div class="line">    (void)arg;</div>
<div class="line">    <span class="keywordflow">if</span> ((event &amp; <a class="code hl_enumvalue" href="group__group__hal__spi.html#ggae8f0cf0233d0225a80815f8282d87b85a3f926937b0199cc8729c443d8e71f91b">CYHAL_SPI_IRQ_DONE</a>) != 0u)</div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Transmission is complete. Handle Event</span></div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> snippet_cyhal_interrupt_callback_events(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line">    <a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>   rslt;</div>
<div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> mSPI;</div>
<div class="line">    uint32_t    spi_frequency = 1000000;</div>
<div class="line">    uint32_t    rx_transfer_count = 5, tx_transfer_count = 5;</div>
<div class="line">    uint8_t     receive_data[5];</div>
<div class="line">    uint8_t     transmit_data[5] = { 0x1, 0x2, 0x3, 0x4, 0x5 };</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Configuring the  SPI interface:  Specify the SPI interface pins, frame size, SPI Motorola</span></div>
<div class="line">    <span class="comment">// mode and master/slave mode</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__spi.html#ga20c9cdb5b051ff8b68cf313fc19b550d">cyhal_spi_init</a>(&amp;mSPI, CYBSP_SPI_MOSI, CYBSP_SPI_MISO, CYBSP_SPI_CLK, CYBSP_SPI_CS, NULL,</div>
<div class="line">                          8, <a class="code hl_enumvalue" href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51a8109c5d0edd4c10a68d82e98bd76de8a">CYHAL_SPI_MODE_00_MSB</a>, <span class="keyword">false</span>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Set the data rate to 1 Mbps</span></div>
<div class="line">    <span class="keywordflow">if</span> (<a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> == rslt)</div>
<div class="line">    {</div>
<div class="line">        rslt = <a class="code hl_function" href="group__group__hal__spi.html#ga536ac25a0556330a35651e32b5c180cb">cyhal_spi_set_frequency</a>(&amp;mSPI, spi_frequency);</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">if</span> (<a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> == rslt)</div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Register a callback function to be called when the interrupt fires</span></div>
<div class="line">        <a class="code hl_function" href="group__group__hal__spi.html#ga5efa8d542f1ab5307d7896a249581a6a">cyhal_spi_register_callback</a>(&amp;mSPI, (<a class="code hl_typedef" href="group__group__hal__spi.html#ga49db139205e26d6150dc9a83338d8a1c">cyhal_spi_event_callback_t</a>)spi_interrupt_callback,</div>
<div class="line">                                    NULL);</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// Enable the events that will trigger the call back function</span></div>
<div class="line">        <a class="code hl_function" href="group__group__hal__spi.html#ga6d53ecb445603a2470ec1fd7e456bba3">cyhal_spi_enable_event</a>(&amp;mSPI, <a class="code hl_enumvalue" href="group__group__hal__spi.html#ggae8f0cf0233d0225a80815f8282d87b85a3f926937b0199cc8729c443d8e71f91b">CYHAL_SPI_IRQ_DONE</a>, 3, <span class="keyword">true</span>);</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// Master: Initiates a data transfer. Slave: Prepares the slave for data transfer. It is a</span></div>
<div class="line">        <span class="comment">// non-blocking function</span></div>
<div class="line">        <span class="keywordflow">if</span> (<a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a> ==</div>
<div class="line">            <a class="code hl_function" href="group__group__hal__spi.html#ga3cbcb44263ba6af2668f8847b8c90210">cyhal_spi_transfer_async</a>(&amp;mSPI, transmit_data, rx_transfer_count, receive_data,</div>
<div class="line">                                     tx_transfer_count))</div>
<div class="line">        {</div>
<div class="line">            <span class="comment">// SPI Master: Transfer started. SPI Slave: Prepares for data transfer</span></div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">return</span> rslt;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__hal__spi_html_ga3cbcb44263ba6af2668f8847b8c90210"><div class="ttname"><a href="group__group__hal__spi.html#ga3cbcb44263ba6af2668f8847b8c90210">cyhal_spi_transfer_async</a></div><div class="ttdeci">cy_rslt_t cyhal_spi_transfer_async(cyhal_spi_t *obj, const uint8_t *tx, size_t tx_length, uint8_t *rx, size_t rx_length)</div><div class="ttdoc">Start an asynchronous SPI transfer.</div></div>
<div class="ttc" id="agroup__group__hal__spi_html_ga49db139205e26d6150dc9a83338d8a1c"><div class="ttname"><a href="group__group__hal__spi.html#ga49db139205e26d6150dc9a83338d8a1c">cyhal_spi_event_callback_t</a></div><div class="ttdeci">void(* cyhal_spi_event_callback_t)(void *callback_arg, cyhal_spi_event_t event)</div><div class="ttdoc">Handler for SPI interrupts.</div><div class="ttdef"><b>Definition:</b> cyhal_spi.h:171</div></div>
<div class="ttc" id="agroup__group__hal__spi_html_ga5efa8d542f1ab5307d7896a249581a6a"><div class="ttname"><a href="group__group__hal__spi.html#ga5efa8d542f1ab5307d7896a249581a6a">cyhal_spi_register_callback</a></div><div class="ttdeci">void cyhal_spi_register_callback(cyhal_spi_t *obj, cyhal_spi_event_callback_t callback, void *callback_arg)</div><div class="ttdoc">Register a SPI callback handler.</div></div>
<div class="ttc" id="agroup__group__hal__spi_html_ga6d53ecb445603a2470ec1fd7e456bba3"><div class="ttname"><a href="group__group__hal__spi.html#ga6d53ecb445603a2470ec1fd7e456bba3">cyhal_spi_enable_event</a></div><div class="ttdeci">void cyhal_spi_enable_event(cyhal_spi_t *obj, cyhal_spi_event_t event, uint8_t intr_priority, bool enable)</div><div class="ttdoc">Configure SPI interrupt.</div></div>
<div class="ttc" id="agroup__group__hal__spi_html_gae8f0cf0233d0225a80815f8282d87b85"><div class="ttname"><a href="group__group__hal__spi.html#gae8f0cf0233d0225a80815f8282d87b85">cyhal_spi_event_t</a></div><div class="ttdeci">cyhal_spi_event_t</div><div class="ttdoc">SPI interrupt triggers.</div><div class="ttdef"><b>Definition:</b> cyhal_spi.h:153</div></div>
<div class="ttc" id="agroup__group__hal__spi_html_ggae8f0cf0233d0225a80815f8282d87b85a3f926937b0199cc8729c443d8e71f91b"><div class="ttname"><a href="group__group__hal__spi.html#ggae8f0cf0233d0225a80815f8282d87b85a3f926937b0199cc8729c443d8e71f91b">CYHAL_SPI_IRQ_DONE</a></div><div class="ttdeci">@ CYHAL_SPI_IRQ_DONE</div><div class="ttdoc">Transfer complete.</div><div class="ttdef"><b>Definition:</b> cyhal_spi.h:157</div></div>
</div><!-- fragment --><h1><a class="anchor" id="subsection_spi_moreinfor"></a>
More Information</h1>
<ul>
<li><a href="https://github.com/infineon/mtb-example-psoc6-spi-master"><b>mtb-example-psoc6-spi-master</b></a>: This example project demonstrates use of SPI (HAL) resource in PSoC® 6 MCU in Master mode to write data to an SPI slave. </li>
</ul>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="groups" name="groups"></a>
API Reference</h2></td></tr>
<tr class="memitem:group__group__hal__results__spi"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__results__spi.html">SPI HAL Results</a></td></tr>
<tr class="memdesc:group__group__hal__results__spi"><td class="mdescLeft">&#160;</td><td class="mdescRight">SPI specific return codes. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:structcyhal__spi__cfg__t"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#structcyhal__spi__cfg__t">cyhal_spi_cfg_t</a></td></tr>
<tr class="memdesc:structcyhal__spi__cfg__t"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initial SPI configuration.  <a href="group__group__hal__spi.html#structcyhal__spi__cfg__t">More...</a><br /></td></tr>
<tr class="separator:structcyhal__spi__cfg__t"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga778a64304a68622c7a3b0f2551d82ea9"><td class="memItemLeft" align="right" valign="top"><a id="ga778a64304a68622c7a3b0f2551d82ea9" name="ga778a64304a68622c7a3b0f2551d82ea9"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>cyhal_spi_frequency</b>&#160;&#160;&#160;<a class="el" href="group__group__hal__spi.html#ga536ac25a0556330a35651e32b5c180cb">cyhal_spi_set_frequency</a></td></tr>
<tr class="memdesc:ga778a64304a68622c7a3b0f2551d82ea9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compatibility define for cyhal_spi_set_frequency. <br /></td></tr>
<tr class="separator:ga778a64304a68622c7a3b0f2551d82ea9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga71078e4a04040e81f171c21bae4269b9"><td class="memItemLeft" align="right" valign="top"><a id="ga71078e4a04040e81f171c21bae4269b9" name="ga71078e4a04040e81f171c21bae4269b9"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>CYHAL_SPI_MODE_FLAG_LSB</b>&#160;&#160;&#160;(0x01u)</td></tr>
<tr class="memdesc:ga71078e4a04040e81f171c21bae4269b9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Flag for SPI <a class="el" href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">cyhal_spi_mode_t</a> values indicating that the LSB is sent first. <br /></td></tr>
<tr class="separator:ga71078e4a04040e81f171c21bae4269b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaad78a88937b2e405bd296dc88d2720d8"><td class="memItemLeft" align="right" valign="top"><a id="gaad78a88937b2e405bd296dc88d2720d8" name="gaad78a88937b2e405bd296dc88d2720d8"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>CYHAL_SPI_MODE_FLAG_CPHA</b>&#160;&#160;&#160;(0x02u)</td></tr>
<tr class="memdesc:gaad78a88937b2e405bd296dc88d2720d8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Flag for SPI <a class="el" href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">cyhal_spi_mode_t</a> values indicating that the CPHA=1. <br /></td></tr>
<tr class="separator:gaad78a88937b2e405bd296dc88d2720d8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga028740fed4f8c4dac07d1b33d68adf94"><td class="memItemLeft" align="right" valign="top"><a id="ga028740fed4f8c4dac07d1b33d68adf94" name="ga028740fed4f8c4dac07d1b33d68adf94"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><b>CYHAL_SPI_MODE_FLAG_CPOL</b>&#160;&#160;&#160;(0x04u)</td></tr>
<tr class="memdesc:ga028740fed4f8c4dac07d1b33d68adf94"><td class="mdescLeft">&#160;</td><td class="mdescRight">Flag for SPI <a class="el" href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">cyhal_spi_mode_t</a> values indicating that the CPOL=1. <br /></td></tr>
<tr class="separator:ga028740fed4f8c4dac07d1b33d68adf94"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga740c6c1f20565a1ae924ec22a9a71cd0"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga740c6c1f20565a1ae924ec22a9a71cd0">CYHAL_SPI_MODE</a>(cpol,  cpha,  lsb)</td></tr>
<tr class="memdesc:ga740c6c1f20565a1ae924ec22a9a71cd0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a <a class="el" href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">cyhal_spi_mode_t</a> value given the cpol, cpha, lsb values.  <a href="group__group__hal__spi.html#ga740c6c1f20565a1ae924ec22a9a71cd0">More...</a><br /></td></tr>
<tr class="separator:ga740c6c1f20565a1ae924ec22a9a71cd0"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ga49db139205e26d6150dc9a83338d8a1c"><td class="memItemLeft" align="right" valign="top"><a id="ga49db139205e26d6150dc9a83338d8a1c" name="ga49db139205e26d6150dc9a83338d8a1c"></a>
typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><b>cyhal_spi_event_callback_t</b>) (void *callback_arg, <a class="el" href="group__group__hal__spi.html#gae8f0cf0233d0225a80815f8282d87b85">cyhal_spi_event_t</a> event)</td></tr>
<tr class="memdesc:ga49db139205e26d6150dc9a83338d8a1c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Handler for SPI interrupts. <br /></td></tr>
<tr class="separator:ga49db139205e26d6150dc9a83338d8a1c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="enum-members" name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:gae8f0cf0233d0225a80815f8282d87b85"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#gae8f0cf0233d0225a80815f8282d87b85">cyhal_spi_event_t</a> { <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggae8f0cf0233d0225a80815f8282d87b85a04910f865434c432b4fb7ba6ee6a4ec5">CYHAL_SPI_IRQ_DATA_IN_FIFO</a> = 1 &lt;&lt; 1
, <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggae8f0cf0233d0225a80815f8282d87b85a3f926937b0199cc8729c443d8e71f91b">CYHAL_SPI_IRQ_DONE</a> = 1 &lt;&lt; 2
, <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggae8f0cf0233d0225a80815f8282d87b85a808355edbb46ce1950705e55f32dc093">CYHAL_SPI_IRQ_ERROR</a> = 1 &lt;&lt; 3
<br />
 }</td></tr>
<tr class="memdesc:gae8f0cf0233d0225a80815f8282d87b85"><td class="mdescLeft">&#160;</td><td class="mdescRight">SPI interrupt triggers.  <a href="group__group__hal__spi.html#gae8f0cf0233d0225a80815f8282d87b85">More...</a><br /></td></tr>
<tr class="separator:gae8f0cf0233d0225a80815f8282d87b85"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabfadf37558e1092ac2fe3a5bd2b912d5"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#gabfadf37558e1092ac2fe3a5bd2b912d5">cyhal_spi_ssel_polarity_t</a> { <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggabfadf37558e1092ac2fe3a5bd2b912d5a3a6c47381becf05d991f9e321ec9fea6">CYHAL_SPI_SSEL_ACTIVE_LOW</a> = 0
, <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggabfadf37558e1092ac2fe3a5bd2b912d5ab9e114bf73df1ff5ae5bab536f96c242">CYHAL_SPI_SSEL_ACTIVE_HIGH</a> = 1
<br />
 }</td></tr>
<tr class="memdesc:gabfadf37558e1092ac2fe3a5bd2b912d5"><td class="mdescLeft">&#160;</td><td class="mdescRight">SPI Slave Select polarity.  <a href="group__group__hal__spi.html#gabfadf37558e1092ac2fe3a5bd2b912d5">More...</a><br /></td></tr>
<tr class="separator:gabfadf37558e1092ac2fe3a5bd2b912d5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf56d895e50b0cf0e858a1ff221c58d51"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">cyhal_spi_mode_t</a> { <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51a8109c5d0edd4c10a68d82e98bd76de8a">CYHAL_SPI_MODE_00_MSB</a> = CYHAL_SPI_MODE(0, 0, 0)
, <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51a33951c55abcba6e01a67fa8252ec81e1">CYHAL_SPI_MODE_00_LSB</a> = CYHAL_SPI_MODE(0, 0, 1)
, <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51a7ddf4f8ed91e1e46728f74581dec24d9">CYHAL_SPI_MODE_01_MSB</a> = CYHAL_SPI_MODE(0, 1, 0)
, <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51a90c2b77bf8ae38974fcb13a25c1c51a2">CYHAL_SPI_MODE_01_LSB</a> = CYHAL_SPI_MODE(0, 1, 1)
, <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51ac8c9a9a943e48c87c0fc550c4645c6cd">CYHAL_SPI_MODE_10_MSB</a> = CYHAL_SPI_MODE(1, 0, 0)
, <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51aae0f7c7fe32a579a9c6226e5472f1ac8">CYHAL_SPI_MODE_10_LSB</a> = CYHAL_SPI_MODE(1, 0, 1)
, <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51a396aa7d1e3a6d7652342a4eb35f91435">CYHAL_SPI_MODE_11_MSB</a> = CYHAL_SPI_MODE(1, 1, 0)
, <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggaf56d895e50b0cf0e858a1ff221c58d51a7987f1cca1342f6f7721c9118f7a7e26">CYHAL_SPI_MODE_11_LSB</a> = CYHAL_SPI_MODE(1, 1, 1)
<br />
 }</td></tr>
<tr class="memdesc:gaf56d895e50b0cf0e858a1ff221c58d51"><td class="mdescLeft">&#160;</td><td class="mdescRight">SPI operating modes.  <a href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">More...</a><br /></td></tr>
<tr class="separator:gaf56d895e50b0cf0e858a1ff221c58d51"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab265880a2da90f74b0452a837e154e0a"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#gab265880a2da90f74b0452a837e154e0a">cyhal_spi_fifo_type_t</a> { <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggab265880a2da90f74b0452a837e154e0aa3537f5b7c757bfca008d47b67a9e9e05">CYHAL_SPI_FIFO_RX</a>
, <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#ggab265880a2da90f74b0452a837e154e0aa6aeb741eed579066debea44d8c02b547">CYHAL_SPI_FIFO_TX</a>
<br />
 }</td></tr>
<tr class="memdesc:gab265880a2da90f74b0452a837e154e0a"><td class="mdescLeft">&#160;</td><td class="mdescRight">SPI FIFO type.  <a href="group__group__hal__spi.html#gab265880a2da90f74b0452a837e154e0a">More...</a><br /></td></tr>
<tr class="separator:gab265880a2da90f74b0452a837e154e0a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1cfefbde3bbc587e57f79e45558ae614"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga1cfefbde3bbc587e57f79e45558ae614">cyhal_spi_output_t</a> { <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#gga1cfefbde3bbc587e57f79e45558ae614ab78da7e222b38d5625a2b5560eaef886">CYHAL_SPI_OUTPUT_TRIGGER_RX_FIFO_LEVEL_REACHED</a>
, <br />
&#160;&#160;<a class="el" href="group__group__hal__spi.html#gga1cfefbde3bbc587e57f79e45558ae614a71ecee2cda10474d296873ff4030c044">CYHAL_SPI_OUTPUT_TRIGGER_TX_FIFO_LEVEL_REACHED</a>
<br />
 }</td></tr>
<tr class="memdesc:ga1cfefbde3bbc587e57f79e45558ae614"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enum of possible output signals from an SPI.  <a href="group__group__hal__spi.html#ga1cfefbde3bbc587e57f79e45558ae614">More...</a><br /></td></tr>
<tr class="separator:ga1cfefbde3bbc587e57f79e45558ae614"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga20c9cdb5b051ff8b68cf313fc19b550d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga20c9cdb5b051ff8b68cf313fc19b550d">cyhal_spi_init</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, <a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a> mosi, <a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a> miso, <a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a> sclk, <a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a> ssel, const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__clock__t">cyhal_clock_t</a> *clk, uint8_t bits, <a class="el" href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">cyhal_spi_mode_t</a> mode, bool is_slave)</td></tr>
<tr class="memdesc:ga20c9cdb5b051ff8b68cf313fc19b550d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the SPI peripheral.  <a href="group__group__hal__spi.html#ga20c9cdb5b051ff8b68cf313fc19b550d">More...</a><br /></td></tr>
<tr class="separator:ga20c9cdb5b051ff8b68cf313fc19b550d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab2bbcc53213e50e43a9bd223573b7870"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#gab2bbcc53213e50e43a9bd223573b7870">cyhal_spi_free</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj)</td></tr>
<tr class="memdesc:gab2bbcc53213e50e43a9bd223573b7870"><td class="mdescLeft">&#160;</td><td class="mdescRight">Release a SPI object.  <a href="group__group__hal__spi.html#gab2bbcc53213e50e43a9bd223573b7870">More...</a><br /></td></tr>
<tr class="separator:gab2bbcc53213e50e43a9bd223573b7870"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga536ac25a0556330a35651e32b5c180cb"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga536ac25a0556330a35651e32b5c180cb">cyhal_spi_set_frequency</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, uint32_t hz)</td></tr>
<tr class="memdesc:ga536ac25a0556330a35651e32b5c180cb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the SPI baud rate.  <a href="group__group__hal__spi.html#ga536ac25a0556330a35651e32b5c180cb">More...</a><br /></td></tr>
<tr class="separator:ga536ac25a0556330a35651e32b5c180cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf933d1bcc357b515bd3cc0ad4518c764"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#gaf933d1bcc357b515bd3cc0ad4518c764">cyhal_spi_slave_select_config</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, <a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a> ssel, <a class="el" href="group__group__hal__spi.html#gabfadf37558e1092ac2fe3a5bd2b912d5">cyhal_spi_ssel_polarity_t</a> polarity)</td></tr>
<tr class="memdesc:gaf933d1bcc357b515bd3cc0ad4518c764"><td class="mdescLeft">&#160;</td><td class="mdescRight">Configures provided ssel pin to work as SPI slave select with specified polarity.  <a href="group__group__hal__spi.html#gaf933d1bcc357b515bd3cc0ad4518c764">More...</a><br /></td></tr>
<tr class="separator:gaf933d1bcc357b515bd3cc0ad4518c764"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab545fa07b788c83398c0265b2e9220c9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#gab545fa07b788c83398c0265b2e9220c9">cyhal_spi_select_active_ssel</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, <a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a> ssel)</td></tr>
<tr class="memdesc:gab545fa07b788c83398c0265b2e9220c9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Selects an active slave select line from one of available.  <a href="group__group__hal__spi.html#gab545fa07b788c83398c0265b2e9220c9">More...</a><br /></td></tr>
<tr class="separator:gab545fa07b788c83398c0265b2e9220c9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad9e6f6399f3096426b718d58e813b0d1"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#gad9e6f6399f3096426b718d58e813b0d1">cyhal_spi_recv</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, uint32_t *value)</td></tr>
<tr class="memdesc:gad9e6f6399f3096426b718d58e813b0d1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Synchronously get a received value out of the SPI receive buffer.  <a href="group__group__hal__spi.html#gad9e6f6399f3096426b718d58e813b0d1">More...</a><br /></td></tr>
<tr class="separator:gad9e6f6399f3096426b718d58e813b0d1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga24b88b94f4869a34a98a54fc0edf9e53"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga24b88b94f4869a34a98a54fc0edf9e53">cyhal_spi_send</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, uint32_t value)</td></tr>
<tr class="memdesc:ga24b88b94f4869a34a98a54fc0edf9e53"><td class="mdescLeft">&#160;</td><td class="mdescRight">Synchronously send a byte out.  <a href="group__group__hal__spi.html#ga24b88b94f4869a34a98a54fc0edf9e53">More...</a><br /></td></tr>
<tr class="separator:ga24b88b94f4869a34a98a54fc0edf9e53"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga25b9d2e7a99b8a08bac915ccedd4fe6b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga25b9d2e7a99b8a08bac915ccedd4fe6b">cyhal_spi_slave_read</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, uint8_t *dst_buff, uint16_t *size, uint32_t timeout)</td></tr>
<tr class="memdesc:ga25b9d2e7a99b8a08bac915ccedd4fe6b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wait for master send data to RX buffer and store them to the user-defined buffer.  <a href="group__group__hal__spi.html#ga25b9d2e7a99b8a08bac915ccedd4fe6b">More...</a><br /></td></tr>
<tr class="separator:ga25b9d2e7a99b8a08bac915ccedd4fe6b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadba53bbb5b0533c9ad50b053e2a63f00"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#gadba53bbb5b0533c9ad50b053e2a63f00">cyhal_spi_slave_write</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, const uint8_t *src_buff, uint16_t *size, uint32_t timeout)</td></tr>
<tr class="memdesc:gadba53bbb5b0533c9ad50b053e2a63f00"><td class="mdescLeft">&#160;</td><td class="mdescRight">Write data from the user-defined buffer to TX buffer.  <a href="group__group__hal__spi.html#gadba53bbb5b0533c9ad50b053e2a63f00">More...</a><br /></td></tr>
<tr class="separator:gadba53bbb5b0533c9ad50b053e2a63f00"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9aac1062d8da58c37bcbe57bf6cc53fd"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga9aac1062d8da58c37bcbe57bf6cc53fd">cyhal_spi_readable</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj)</td></tr>
<tr class="memdesc:ga9aac1062d8da58c37bcbe57bf6cc53fd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the number of bytes that can be read from the RX buffer.  <a href="group__group__hal__spi.html#ga9aac1062d8da58c37bcbe57bf6cc53fd">More...</a><br /></td></tr>
<tr class="separator:ga9aac1062d8da58c37bcbe57bf6cc53fd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga45d9af3604ae1c1d9dc2aa271db26d37"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga45d9af3604ae1c1d9dc2aa271db26d37">cyhal_spi_writable</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj)</td></tr>
<tr class="memdesc:ga45d9af3604ae1c1d9dc2aa271db26d37"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the number of bytes that can be written to the TX buffer.  <a href="group__group__hal__spi.html#ga45d9af3604ae1c1d9dc2aa271db26d37">More...</a><br /></td></tr>
<tr class="separator:ga45d9af3604ae1c1d9dc2aa271db26d37"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad21547fa4048c45f15308c0b1ff62c1f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#gad21547fa4048c45f15308c0b1ff62c1f">cyhal_spi_transfer</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, const uint8_t *tx, size_t tx_length, uint8_t *rx, size_t rx_length, uint8_t write_fill)</td></tr>
<tr class="memdesc:gad21547fa4048c45f15308c0b1ff62c1f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Synchronously Write a block out and receive a value.  <a href="group__group__hal__spi.html#gad21547fa4048c45f15308c0b1ff62c1f">More...</a><br /></td></tr>
<tr class="separator:gad21547fa4048c45f15308c0b1ff62c1f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3cbcb44263ba6af2668f8847b8c90210"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga3cbcb44263ba6af2668f8847b8c90210">cyhal_spi_transfer_async</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, const uint8_t *tx, size_t tx_length, uint8_t *rx, size_t rx_length)</td></tr>
<tr class="memdesc:ga3cbcb44263ba6af2668f8847b8c90210"><td class="mdescLeft">&#160;</td><td class="mdescRight">Start an asynchronous SPI transfer.  <a href="group__group__hal__spi.html#ga3cbcb44263ba6af2668f8847b8c90210">More...</a><br /></td></tr>
<tr class="separator:ga3cbcb44263ba6af2668f8847b8c90210"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga94cd6755137c445776a75f29af355cab"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga94cd6755137c445776a75f29af355cab">cyhal_spi_is_busy</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj)</td></tr>
<tr class="memdesc:ga94cd6755137c445776a75f29af355cab"><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks if the specified SPI peripheral is in use.  <a href="group__group__hal__spi.html#ga94cd6755137c445776a75f29af355cab">More...</a><br /></td></tr>
<tr class="separator:ga94cd6755137c445776a75f29af355cab"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2d4d48b53480a80e11d6ae5ebd01c0c2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga2d4d48b53480a80e11d6ae5ebd01c0c2">cyhal_spi_abort_async</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj)</td></tr>
<tr class="memdesc:ga2d4d48b53480a80e11d6ae5ebd01c0c2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Abort an SPI transfer.  <a href="group__group__hal__spi.html#ga2d4d48b53480a80e11d6ae5ebd01c0c2">More...</a><br /></td></tr>
<tr class="separator:ga2d4d48b53480a80e11d6ae5ebd01c0c2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5efa8d542f1ab5307d7896a249581a6a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga5efa8d542f1ab5307d7896a249581a6a">cyhal_spi_register_callback</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, <a class="el" href="group__group__hal__spi.html#ga49db139205e26d6150dc9a83338d8a1c">cyhal_spi_event_callback_t</a> callback, void *callback_arg)</td></tr>
<tr class="memdesc:ga5efa8d542f1ab5307d7896a249581a6a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Register a SPI callback handler.  <a href="group__group__hal__spi.html#ga5efa8d542f1ab5307d7896a249581a6a">More...</a><br /></td></tr>
<tr class="separator:ga5efa8d542f1ab5307d7896a249581a6a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6d53ecb445603a2470ec1fd7e456bba3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga6d53ecb445603a2470ec1fd7e456bba3">cyhal_spi_enable_event</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, <a class="el" href="group__group__hal__spi.html#gae8f0cf0233d0225a80815f8282d87b85">cyhal_spi_event_t</a> event, uint8_t intr_priority, bool enable)</td></tr>
<tr class="memdesc:ga6d53ecb445603a2470ec1fd7e456bba3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Configure SPI interrupt.  <a href="group__group__hal__spi.html#ga6d53ecb445603a2470ec1fd7e456bba3">More...</a><br /></td></tr>
<tr class="separator:ga6d53ecb445603a2470ec1fd7e456bba3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa8f39b8e84c0925cb2f3ea44668de63b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#gaa8f39b8e84c0925cb2f3ea44668de63b">cyhal_spi_set_fifo_level</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, <a class="el" href="group__group__hal__spi.html#gab265880a2da90f74b0452a837e154e0a">cyhal_spi_fifo_type_t</a> type, uint16_t level)</td></tr>
<tr class="memdesc:gaa8f39b8e84c0925cb2f3ea44668de63b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets a threshold level for a FIFO that will generate an interrupt and a trigger output.  <a href="group__group__hal__spi.html#gaa8f39b8e84c0925cb2f3ea44668de63b">More...</a><br /></td></tr>
<tr class="separator:gaa8f39b8e84c0925cb2f3ea44668de63b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga98fbe6cea252e705ea4bd219376cc8a1"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga98fbe6cea252e705ea4bd219376cc8a1">cyhal_spi_enable_output</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, <a class="el" href="group__group__hal__spi.html#ga1cfefbde3bbc587e57f79e45558ae614">cyhal_spi_output_t</a> output, <a class="el" href="group__group__hal__impl__triggers__psoc6__01.html#ga96236d1368f920d28af90262e8b57046">cyhal_source_t</a> *source)</td></tr>
<tr class="memdesc:ga98fbe6cea252e705ea4bd219376cc8a1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enables the specified output signal from an SPI.  <a href="group__group__hal__spi.html#ga98fbe6cea252e705ea4bd219376cc8a1">More...</a><br /></td></tr>
<tr class="separator:ga98fbe6cea252e705ea4bd219376cc8a1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae7dae4894227e55b9315d75737fa3e24"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#gae7dae4894227e55b9315d75737fa3e24">cyhal_spi_disable_output</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, <a class="el" href="group__group__hal__spi.html#ga1cfefbde3bbc587e57f79e45558ae614">cyhal_spi_output_t</a> output)</td></tr>
<tr class="memdesc:gae7dae4894227e55b9315d75737fa3e24"><td class="mdescLeft">&#160;</td><td class="mdescRight">Disables the specified output signal from an SPI.  <a href="group__group__hal__spi.html#gae7dae4894227e55b9315d75737fa3e24">More...</a><br /></td></tr>
<tr class="separator:gae7dae4894227e55b9315d75737fa3e24"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga325d0890195400a2d1e4e994cd24fa09"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga325d0890195400a2d1e4e994cd24fa09">cyhal_spi_init_cfg</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj, const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__configurator__t">cyhal_spi_configurator_t</a> *cfg)</td></tr>
<tr class="memdesc:ga325d0890195400a2d1e4e994cd24fa09"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the SPI peripheral using a configurator generated configuration struct.  <a href="group__group__hal__spi.html#ga325d0890195400a2d1e4e994cd24fa09">More...</a><br /></td></tr>
<tr class="separator:ga325d0890195400a2d1e4e994cd24fa09"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga561c87eefd7d265448e646cc2f1c1ae3"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__spi.html#ga561c87eefd7d265448e646cc2f1c1ae3">cyhal_spi_clear</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *obj)</td></tr>
<tr class="memdesc:ga561c87eefd7d265448e646cc2f1c1ae3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clear the SPI buffers.  <a href="group__group__hal__spi.html#ga561c87eefd7d265448e646cc2f1c1ae3">More...</a><br /></td></tr>
<tr class="separator:ga561c87eefd7d265448e646cc2f1c1ae3"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<hr/><h2 class="groupheader">Data Structure Documentation</h2>
<a name="structcyhal__spi__cfg__t" id="structcyhal__spi__cfg__t"></a>
<h2 class="memtitle"><span class="permalink"><a href="#structcyhal__spi__cfg__t">&#9670;&nbsp;</a></span>cyhal_spi_cfg_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct cyhal_spi_cfg_t</td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="3">Data Fields</th></tr>
<tr><td class="fieldtype">
<a id="a031d638b78c9d9e2d62f98352b3fe3cf" name="a031d638b78c9d9e2d62f98352b3fe3cf"></a><a class="el" href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">cyhal_spi_mode_t</a></td>
<td class="fieldname">
mode</td>
<td class="fielddoc">
The operating mode. </td></tr>
<tr><td class="fieldtype">
<a id="a1991eaa6f8caf9cb6ad1346615158636" name="a1991eaa6f8caf9cb6ad1346615158636"></a>uint8_t</td>
<td class="fieldname">
data_bits</td>
<td class="fielddoc">
The number of bits per transfer. </td></tr>
<tr><td class="fieldtype">
<a id="afbea547c3e4cbe19a70781e361f9c1dc" name="afbea547c3e4cbe19a70781e361f9c1dc"></a>bool</td>
<td class="fieldname">
is_slave</td>
<td class="fielddoc">
Whether the peripheral is operating as slave or master. </td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ga740c6c1f20565a1ae924ec22a9a71cd0" name="ga740c6c1f20565a1ae924ec22a9a71cd0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga740c6c1f20565a1ae924ec22a9a71cd0">&#9670;&nbsp;</a></span>CYHAL_SPI_MODE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define CYHAL_SPI_MODE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">cpol, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">cpha, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">lsb&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">                                             ((((cpol) &gt; 0) ? <a class="code hl_define" href="group__group__hal__spi.html#ga028740fed4f8c4dac07d1b33d68adf94">CYHAL_SPI_MODE_FLAG_CPOL</a> : 0) | \</div>
<div class="line">                                             (((cpha) &gt; 0) ? <a class="code hl_define" href="group__group__hal__spi.html#gaad78a88937b2e405bd296dc88d2720d8">CYHAL_SPI_MODE_FLAG_CPHA</a> : 0) | \</div>
<div class="line">                                              (((lsb) &gt; 0) ? <a class="code hl_define" href="group__group__hal__spi.html#ga71078e4a04040e81f171c21bae4269b9">CYHAL_SPI_MODE_FLAG_LSB</a>  : 0))</div>
<div class="ttc" id="agroup__group__hal__spi_html_ga028740fed4f8c4dac07d1b33d68adf94"><div class="ttname"><a href="group__group__hal__spi.html#ga028740fed4f8c4dac07d1b33d68adf94">CYHAL_SPI_MODE_FLAG_CPOL</a></div><div class="ttdeci">#define CYHAL_SPI_MODE_FLAG_CPOL</div><div class="ttdoc">Flag for SPI cyhal_spi_mode_t values indicating that the CPOL=1.</div><div class="ttdef"><b>Definition:</b> cyhal_spi.h:178</div></div>
<div class="ttc" id="agroup__group__hal__spi_html_ga71078e4a04040e81f171c21bae4269b9"><div class="ttname"><a href="group__group__hal__spi.html#ga71078e4a04040e81f171c21bae4269b9">CYHAL_SPI_MODE_FLAG_LSB</a></div><div class="ttdeci">#define CYHAL_SPI_MODE_FLAG_LSB</div><div class="ttdoc">Flag for SPI cyhal_spi_mode_t values indicating that the LSB is sent first.</div><div class="ttdef"><b>Definition:</b> cyhal_spi.h:174</div></div>
<div class="ttc" id="agroup__group__hal__spi_html_gaad78a88937b2e405bd296dc88d2720d8"><div class="ttname"><a href="group__group__hal__spi.html#gaad78a88937b2e405bd296dc88d2720d8">CYHAL_SPI_MODE_FLAG_CPHA</a></div><div class="ttdeci">#define CYHAL_SPI_MODE_FLAG_CPHA</div><div class="ttdoc">Flag for SPI cyhal_spi_mode_t values indicating that the CPHA=1.</div><div class="ttdef"><b>Definition:</b> cyhal_spi.h:176</div></div>
</div><!-- fragment -->
<p>Creates a <a class="el" href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">cyhal_spi_mode_t</a> value given the cpol, cpha, lsb values. </p>

</div>
</div>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a id="gae8f0cf0233d0225a80815f8282d87b85" name="gae8f0cf0233d0225a80815f8282d87b85"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae8f0cf0233d0225a80815f8282d87b85">&#9670;&nbsp;</a></span>cyhal_spi_event_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__group__hal__spi.html#gae8f0cf0233d0225a80815f8282d87b85">cyhal_spi_event_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>SPI interrupt triggers. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="ggae8f0cf0233d0225a80815f8282d87b85a04910f865434c432b4fb7ba6ee6a4ec5" name="ggae8f0cf0233d0225a80815f8282d87b85a04910f865434c432b4fb7ba6ee6a4ec5"></a>CYHAL_SPI_IRQ_DATA_IN_FIFO&#160;</td><td class="fielddoc"><p >All transfer data has been moved into data FIFO. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggae8f0cf0233d0225a80815f8282d87b85a3f926937b0199cc8729c443d8e71f91b" name="ggae8f0cf0233d0225a80815f8282d87b85a3f926937b0199cc8729c443d8e71f91b"></a>CYHAL_SPI_IRQ_DONE&#160;</td><td class="fielddoc"><p >Transfer complete. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggae8f0cf0233d0225a80815f8282d87b85a808355edbb46ce1950705e55f32dc093" name="ggae8f0cf0233d0225a80815f8282d87b85a808355edbb46ce1950705e55f32dc093"></a>CYHAL_SPI_IRQ_ERROR&#160;</td><td class="fielddoc"><p >An error occurred while transferring data. </p>
</td></tr>
</table>

</div>
</div>
<a id="gabfadf37558e1092ac2fe3a5bd2b912d5" name="gabfadf37558e1092ac2fe3a5bd2b912d5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gabfadf37558e1092ac2fe3a5bd2b912d5">&#9670;&nbsp;</a></span>cyhal_spi_ssel_polarity_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__group__hal__spi.html#gabfadf37558e1092ac2fe3a5bd2b912d5">cyhal_spi_ssel_polarity_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>SPI Slave Select polarity. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="ggabfadf37558e1092ac2fe3a5bd2b912d5a3a6c47381becf05d991f9e321ec9fea6" name="ggabfadf37558e1092ac2fe3a5bd2b912d5a3a6c47381becf05d991f9e321ec9fea6"></a>CYHAL_SPI_SSEL_ACTIVE_LOW&#160;</td><td class="fielddoc"><p >SSEL signal is active low. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggabfadf37558e1092ac2fe3a5bd2b912d5ab9e114bf73df1ff5ae5bab536f96c242" name="ggabfadf37558e1092ac2fe3a5bd2b912d5ab9e114bf73df1ff5ae5bab536f96c242"></a>CYHAL_SPI_SSEL_ACTIVE_HIGH&#160;</td><td class="fielddoc"><p >SSEL signal is active high. </p>
</td></tr>
</table>

</div>
</div>
<a id="gaf56d895e50b0cf0e858a1ff221c58d51" name="gaf56d895e50b0cf0e858a1ff221c58d51"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf56d895e50b0cf0e858a1ff221c58d51">&#9670;&nbsp;</a></span>cyhal_spi_mode_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">cyhal_spi_mode_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>SPI operating modes. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="ggaf56d895e50b0cf0e858a1ff221c58d51a8109c5d0edd4c10a68d82e98bd76de8a" name="ggaf56d895e50b0cf0e858a1ff221c58d51a8109c5d0edd4c10a68d82e98bd76de8a"></a>CYHAL_SPI_MODE_00_MSB&#160;</td><td class="fielddoc"><p >Standard motorola SPI CPOL=0, CPHA=0 with MSB first operation. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggaf56d895e50b0cf0e858a1ff221c58d51a33951c55abcba6e01a67fa8252ec81e1" name="ggaf56d895e50b0cf0e858a1ff221c58d51a33951c55abcba6e01a67fa8252ec81e1"></a>CYHAL_SPI_MODE_00_LSB&#160;</td><td class="fielddoc"><p >Standard motorola SPI CPOL=0, CPHA=0 with LSB first operation. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggaf56d895e50b0cf0e858a1ff221c58d51a7ddf4f8ed91e1e46728f74581dec24d9" name="ggaf56d895e50b0cf0e858a1ff221c58d51a7ddf4f8ed91e1e46728f74581dec24d9"></a>CYHAL_SPI_MODE_01_MSB&#160;</td><td class="fielddoc"><p >Standard motorola SPI CPOL=0, CPHA=1 with MSB first operation. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggaf56d895e50b0cf0e858a1ff221c58d51a90c2b77bf8ae38974fcb13a25c1c51a2" name="ggaf56d895e50b0cf0e858a1ff221c58d51a90c2b77bf8ae38974fcb13a25c1c51a2"></a>CYHAL_SPI_MODE_01_LSB&#160;</td><td class="fielddoc"><p >Standard motorola SPI CPOL=0, CPHA=1 with LSB first operation. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggaf56d895e50b0cf0e858a1ff221c58d51ac8c9a9a943e48c87c0fc550c4645c6cd" name="ggaf56d895e50b0cf0e858a1ff221c58d51ac8c9a9a943e48c87c0fc550c4645c6cd"></a>CYHAL_SPI_MODE_10_MSB&#160;</td><td class="fielddoc"><p >Standard motorola SPI CPOL=1, CPHA=0 with MSB first operation. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggaf56d895e50b0cf0e858a1ff221c58d51aae0f7c7fe32a579a9c6226e5472f1ac8" name="ggaf56d895e50b0cf0e858a1ff221c58d51aae0f7c7fe32a579a9c6226e5472f1ac8"></a>CYHAL_SPI_MODE_10_LSB&#160;</td><td class="fielddoc"><p >Standard motorola SPI CPOL=1, CPHA=0 with LSB first operation. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggaf56d895e50b0cf0e858a1ff221c58d51a396aa7d1e3a6d7652342a4eb35f91435" name="ggaf56d895e50b0cf0e858a1ff221c58d51a396aa7d1e3a6d7652342a4eb35f91435"></a>CYHAL_SPI_MODE_11_MSB&#160;</td><td class="fielddoc"><p >Standard motorola SPI CPOL=1, CPHA=1 with MSB first operation. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggaf56d895e50b0cf0e858a1ff221c58d51a7987f1cca1342f6f7721c9118f7a7e26" name="ggaf56d895e50b0cf0e858a1ff221c58d51a7987f1cca1342f6f7721c9118f7a7e26"></a>CYHAL_SPI_MODE_11_LSB&#160;</td><td class="fielddoc"><p >Standard motorola SPI CPOL=1, CPHA=1 with LSB first operation. </p>
</td></tr>
</table>

</div>
</div>
<a id="gab265880a2da90f74b0452a837e154e0a" name="gab265880a2da90f74b0452a837e154e0a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab265880a2da90f74b0452a837e154e0a">&#9670;&nbsp;</a></span>cyhal_spi_fifo_type_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__group__hal__spi.html#gab265880a2da90f74b0452a837e154e0a">cyhal_spi_fifo_type_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>SPI FIFO type. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="ggab265880a2da90f74b0452a837e154e0aa3537f5b7c757bfca008d47b67a9e9e05" name="ggab265880a2da90f74b0452a837e154e0aa3537f5b7c757bfca008d47b67a9e9e05"></a>CYHAL_SPI_FIFO_RX&#160;</td><td class="fielddoc"><p >Set RX FIFO level. </p>
</td></tr>
<tr><td class="fieldname"><a id="ggab265880a2da90f74b0452a837e154e0aa6aeb741eed579066debea44d8c02b547" name="ggab265880a2da90f74b0452a837e154e0aa6aeb741eed579066debea44d8c02b547"></a>CYHAL_SPI_FIFO_TX&#160;</td><td class="fielddoc"><p >Set TX FIFO level. </p>
</td></tr>
</table>

</div>
</div>
<a id="ga1cfefbde3bbc587e57f79e45558ae614" name="ga1cfefbde3bbc587e57f79e45558ae614"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga1cfefbde3bbc587e57f79e45558ae614">&#9670;&nbsp;</a></span>cyhal_spi_output_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__group__hal__spi.html#ga1cfefbde3bbc587e57f79e45558ae614">cyhal_spi_output_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Enum of possible output signals from an SPI. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="gga1cfefbde3bbc587e57f79e45558ae614ab78da7e222b38d5625a2b5560eaef886" name="gga1cfefbde3bbc587e57f79e45558ae614ab78da7e222b38d5625a2b5560eaef886"></a>CYHAL_SPI_OUTPUT_TRIGGER_RX_FIFO_LEVEL_REACHED&#160;</td><td class="fielddoc"><p >Output the RX FIFO signal which is triggered when the receive FIFO has more entries than the configured level. </p>
</td></tr>
<tr><td class="fieldname"><a id="gga1cfefbde3bbc587e57f79e45558ae614a71ecee2cda10474d296873ff4030c044" name="gga1cfefbde3bbc587e57f79e45558ae614a71ecee2cda10474d296873ff4030c044"></a>CYHAL_SPI_OUTPUT_TRIGGER_TX_FIFO_LEVEL_REACHED&#160;</td><td class="fielddoc"><p >Output the TX FIFO signal which is triggered when the transmit FIFO has less entries than the configured level. </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga20c9cdb5b051ff8b68cf313fc19b550d" name="ga20c9cdb5b051ff8b68cf313fc19b550d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga20c9cdb5b051ff8b68cf313fc19b550d">&#9670;&nbsp;</a></span>cyhal_spi_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_init </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a>&#160;</td>
          <td class="paramname"><em>mosi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a>&#160;</td>
          <td class="paramname"><em>miso</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a>&#160;</td>
          <td class="paramname"><em>sclk</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a>&#160;</td>
          <td class="paramname"><em>ssel</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__clock__t">cyhal_clock_t</a> *&#160;</td>
          <td class="paramname"><em>clk</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>bits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__spi.html#gaf56d895e50b0cf0e858a1ff221c58d51">cyhal_spi_mode_t</a>&#160;</td>
          <td class="paramname"><em>mode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>is_slave</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize the SPI peripheral. </p>
<p >Configures the pins used by SPI, sets a default format and frequency, and enables the peripheral. Depending on the configuration, some pins may not be needed. Master mode: MOSI used, MISO unused: SCLK &amp; SSEL are both optional Master mode: MISO used, MOSI unused: SCLK is mandatory, SSEL is optional Slave mode: MOSI or MISO are used: SCLK &amp; SSEL are both mandatory</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">obj</td><td>Pointer to a SPI object. The caller must allocate the memory for this object but the init function will initialize its contents. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">mosi</td><td>The pin to use for MOSI </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>At least MOSI or MISO pin should be non-NC </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">miso</td><td>The pin to use for MISO </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>At least MOSI or MISO pin should be non-NC </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">sclk</td><td>The pin to use for SCLK </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>This pin can be NC if in master mode with only MOSI used </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">ssel</td><td>The pin to use for SSEL </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>Provided pin will be configured for <a class="el" href="group__group__hal__spi.html#ggabfadf37558e1092ac2fe3a5bd2b912d5a3a6c47381becf05d991f9e321ec9fea6">CYHAL_SPI_SSEL_ACTIVE_LOW</a> polarity and set as active. This can be changed (as well as additional ssel pins can be added) by <a class="el" href="group__group__hal__spi.html#gaf933d1bcc357b515bd3cc0ad4518c764">cyhal_spi_slave_select_config</a> and <a class="el" href="group__group__hal__spi.html#gab545fa07b788c83398c0265b2e9220c9">cyhal_spi_select_active_ssel</a> functions. This pin can be NC. </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">clk</td><td>The clock to use can be shared, if not provided a new clock will be allocated </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">bits</td><td>The number of bits per frame </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd><a class="el" href="group__group__hal__impl__spi.html#section_hal_impl_spi_data_width">Supported transfer data width options</a> describes what data width options are supported by certain hardware </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">mode</td><td>The SPI mode (clock polarity, phase, and shift direction) </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">is_slave</td><td>false for master mode or true for slave mode operation </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the init request </dd></dl>

</div>
</div>
<a id="gab2bbcc53213e50e43a9bd223573b7870" name="gab2bbcc53213e50e43a9bd223573b7870"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab2bbcc53213e50e43a9bd223573b7870">&#9670;&nbsp;</a></span>cyhal_spi_free()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cyhal_spi_free </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Release a SPI object. </p>
<p >Return the peripheral, pins and clock owned by the SPI object to their reset state </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">obj</td><td>The SPI object to deinitialize </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga536ac25a0556330a35651e32b5c180cb" name="ga536ac25a0556330a35651e32b5c180cb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga536ac25a0556330a35651e32b5c180cb">&#9670;&nbsp;</a></span>cyhal_spi_set_frequency()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_set_frequency </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>hz</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set the SPI baud rate. </p>
<p >Actual frequency may differ from the desired frequency due to available dividers and bus clock Configures the SPI peripheral's baud rate </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">obj</td><td>The SPI object to configure </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">hz</td><td>The baud rate in Hz </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the set_frequency request </dd></dl>

</div>
</div>
<a id="gaf933d1bcc357b515bd3cc0ad4518c764" name="gaf933d1bcc357b515bd3cc0ad4518c764"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf933d1bcc357b515bd3cc0ad4518c764">&#9670;&nbsp;</a></span>cyhal_spi_slave_select_config()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_slave_select_config </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a>&#160;</td>
          <td class="paramname"><em>ssel</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__spi.html#gabfadf37558e1092ac2fe3a5bd2b912d5">cyhal_spi_ssel_polarity_t</a>&#160;</td>
          <td class="paramname"><em>polarity</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Configures provided ssel pin to work as SPI slave select with specified polarity. </p>
<p >Multiple pins can be configured as SPI slave select pins. Please refer to device datasheet for details. Switching between configured slave select pins is done by <a class="el" href="group__group__hal__spi.html#gab545fa07b788c83398c0265b2e9220c9">cyhal_spi_select_active_ssel</a> function. Unless modified with this function, the SSEL pin provided as part of <a class="el" href="group__group__hal__spi.html#ga20c9cdb5b051ff8b68cf313fc19b550d">cyhal_spi_init</a> is the default. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object to add slave select for </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">ssel</td><td>Slave select pin to be added </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">polarity</td><td>Polarity of slave select </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of ssel pin configuration </dd></dl>

</div>
</div>
<a id="gab545fa07b788c83398c0265b2e9220c9" name="gab545fa07b788c83398c0265b2e9220c9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab545fa07b788c83398c0265b2e9220c9">&#9670;&nbsp;</a></span>cyhal_spi_select_active_ssel()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_select_active_ssel </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a>&#160;</td>
          <td class="paramname"><em>ssel</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Selects an active slave select line from one of available. </p>
<p >This function is applicable for the master and slave. SSEL pin should be configured by <a class="el" href="group__group__hal__spi.html#gaf933d1bcc357b515bd3cc0ad4518c764">cyhal_spi_slave_select_config</a> or <a class="el" href="group__group__hal__spi.html#ga20c9cdb5b051ff8b68cf313fc19b550d">cyhal_spi_init</a> functions prior to selecting it as active. The active slave select line will automatically be toggled as part of any transfer. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object for switching </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">ssel</td><td>Slave select pin to be set as active </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>CY_RSLT_SUCCESS if slave select was switched successfully, otherwise - CYHAL_SPI_RSLT_ERR_CANNOT_SWITCH_SSEL </dd></dl>

</div>
</div>
<a id="gad9e6f6399f3096426b718d58e813b0d1" name="gad9e6f6399f3096426b718d58e813b0d1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad9e6f6399f3096426b718d58e813b0d1">&#9670;&nbsp;</a></span>cyhal_spi_recv()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_recv </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t *&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Synchronously get a received value out of the SPI receive buffer. </p>
<p >In Master mode - transmits fill-in value and read the data from RxFifo In Slave mode - Blocks until a value is available</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI peripheral to read </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">value</td><td>The value received </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the read request </dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>In Master mode, MISO pin required to be non-NC for this API to operate</li>
<li>In Slave mode, MOSI pin required to be non-NC for this API to operate </li>
</ul>
</dd></dl>

</div>
</div>
<a id="ga24b88b94f4869a34a98a54fc0edf9e53" name="ga24b88b94f4869a34a98a54fc0edf9e53"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga24b88b94f4869a34a98a54fc0edf9e53">&#9670;&nbsp;</a></span>cyhal_spi_send()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_send </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Synchronously send a byte out. </p>
<p >In Master mode transmits value to slave and read/drop a value from the RxFifo. In Slave mode writes a value to TxFifo</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI peripheral to use for sending </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">value</td><td>The value to send </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the write request </dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>In Master mode, MOSI pin required to be non-NC for this API to operate</li>
<li>In Slave mode, MISO pin required to be non-NC for this API to operate </li>
</ul>
</dd></dl>

</div>
</div>
<a id="ga25b9d2e7a99b8a08bac915ccedd4fe6b" name="ga25b9d2e7a99b8a08bac915ccedd4fe6b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga25b9d2e7a99b8a08bac915ccedd4fe6b">&#9670;&nbsp;</a></span>cyhal_spi_slave_read()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_slave_read </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>dst_buff</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t *&#160;</td>
          <td class="paramname"><em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>timeout</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Wait for master send data to RX buffer and store them to the user-defined buffer. </p>
<p >NOTE: If size of actual data is less then expected the function copy only available data.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dst_buff</td><td>Pointer on memory to store the data from the slave RX buffer. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">size</td><td>[in] The number of bytes to read, [out] number actually read. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">timeout</td><td>Timeout in millisecond, set this value to 0 if you don't want to wait at all. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the read request </dd></dl>

</div>
</div>
<a id="gadba53bbb5b0533c9ad50b053e2a63f00" name="gadba53bbb5b0533c9ad50b053e2a63f00"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadba53bbb5b0533c9ad50b053e2a63f00">&#9670;&nbsp;</a></span>cyhal_spi_slave_write()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_slave_write </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>src_buff</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t *&#160;</td>
          <td class="paramname"><em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>timeout</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Write data from the user-defined buffer to TX buffer. </p>
<p >NOTE: If size of actual data is less then expected the function copy only available data.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">src_buff</td><td>Pointer on memory to copy the data to the slave TX buffer. </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">size</td><td>[in] The number of bytes to send, [out] number actually sent. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">timeout</td><td>Timeout in millisecond, set this value to 0 if you don't want to wait at all. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the write request </dd></dl>

</div>
</div>
<a id="ga9aac1062d8da58c37bcbe57bf6cc53fd" name="ga9aac1062d8da58c37bcbe57bf6cc53fd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9aac1062d8da58c37bcbe57bf6cc53fd">&#9670;&nbsp;</a></span>cyhal_spi_readable()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t cyhal_spi_readable </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the number of bytes that can be read from the RX buffer. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of bytes in the RX buffer. </dd></dl>

</div>
</div>
<a id="ga45d9af3604ae1c1d9dc2aa271db26d37" name="ga45d9af3604ae1c1d9dc2aa271db26d37"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga45d9af3604ae1c1d9dc2aa271db26d37">&#9670;&nbsp;</a></span>cyhal_spi_writable()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t cyhal_spi_writable </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the number of bytes that can be written to the TX buffer. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of bytes that can be written </dd></dl>

</div>
</div>
<a id="gad21547fa4048c45f15308c0b1ff62c1f" name="gad21547fa4048c45f15308c0b1ff62c1f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad21547fa4048c45f15308c0b1ff62c1f">&#9670;&nbsp;</a></span>cyhal_spi_transfer()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_transfer </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>tx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>tx_length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>rx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>rx_length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>write_fill</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Synchronously Write a block out and receive a value. </p>
<p >The total number of bytes sent and received will be the maximum of tx_length and rx_length. The bytes written will be padded (at the end) with the value given by write_fill.</p>
<p >This function will block for the duration of the transfer. <a class="el" href="group__group__hal__spi.html#ga3cbcb44263ba6af2668f8847b8c90210">cyhal_spi_transfer_async</a> can be used for non-blocking transfers.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI peripheral to use for sending </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">tx</td><td>Pointer to the byte-array of data to write to the device </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">tx_length</td><td>Number of bytes to write, updated with the number actually written </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">rx</td><td>Pointer to the byte-array of data to read from the device </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">rx_length</td><td>Number of bytes to read, updated with the number actually read </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">write_fill</td><td>Default data transmitted while performing a read </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the transfer request </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Both MOSI and MISO pins required to be non-NC for this API to operate </dd></dl>

</div>
</div>
<a id="ga3cbcb44263ba6af2668f8847b8c90210" name="ga3cbcb44263ba6af2668f8847b8c90210"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3cbcb44263ba6af2668f8847b8c90210">&#9670;&nbsp;</a></span>cyhal_spi_transfer_async()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_transfer_async </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>tx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>tx_length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>rx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>rx_length</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Start an asynchronous SPI transfer. </p>
<p >This will transfer <code>rx_length</code> bytes into the buffer pointed to by <code>rx</code>, while simultaneously transfering <code>tx_length</code> bytes of data from the buffer pointed to by <code>tx</code>, both in the background. When the transfer is complete, the <a class="el" href="group__group__hal__spi.html#ggae8f0cf0233d0225a80815f8282d87b85a3f926937b0199cc8729c443d8e71f91b">CYHAL_SPI_IRQ_DONE</a> event will be raised. See <a class="el" href="group__group__hal__spi.html#ga5efa8d542f1ab5307d7896a249581a6a">cyhal_spi_register_callback</a> and <a class="el" href="group__group__hal__spi.html#ga6d53ecb445603a2470ec1fd7e456bba3">cyhal_spi_enable_event</a>. </p><dl class="section note"><dt>Note</dt><dd>For blocking transfers cyhal_spi_transfer can be used.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object that holds the transfer information </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">tx</td><td>The transmit buffer </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">tx_length</td><td>The number of bytes to transmit </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">rx</td><td>The receive buffer </td></tr>
    <tr><td class="paramdir">[in,out]</td><td class="paramname">rx_length</td><td>The number of bytes to receive </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the transfer_async request </dd></dl>
<dl class="section note"><dt>Note</dt><dd>Both MOSI and MISO pins required to be non-NC for this API to operate </dd></dl>

</div>
</div>
<a id="ga94cd6755137c445776a75f29af355cab" name="ga94cd6755137c445776a75f29af355cab"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga94cd6755137c445776a75f29af355cab">&#9670;&nbsp;</a></span>cyhal_spi_is_busy()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cyhal_spi_is_busy </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Checks if the specified SPI peripheral is in use. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI peripheral to check </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Indication of whether the SPI is still transmitting </dd></dl>

</div>
</div>
<a id="ga2d4d48b53480a80e11d6ae5ebd01c0c2" name="ga2d4d48b53480a80e11d6ae5ebd01c0c2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2d4d48b53480a80e11d6ae5ebd01c0c2">&#9670;&nbsp;</a></span>cyhal_spi_abort_async()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_abort_async </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Abort an SPI transfer. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI peripheral to stop </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the abort_async request </dd></dl>

</div>
</div>
<a id="ga5efa8d542f1ab5307d7896a249581a6a" name="ga5efa8d542f1ab5307d7896a249581a6a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5efa8d542f1ab5307d7896a249581a6a">&#9670;&nbsp;</a></span>cyhal_spi_register_callback()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cyhal_spi_register_callback </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__spi.html#ga49db139205e26d6150dc9a83338d8a1c">cyhal_spi_event_callback_t</a>&#160;</td>
          <td class="paramname"><em>callback</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>callback_arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Register a SPI callback handler. </p>
<p >This function will be called when one of the events enabled by <a class="el" href="group__group__hal__spi.html#ga6d53ecb445603a2470ec1fd7e456bba3">cyhal_spi_enable_event</a> occurs.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">callback</td><td>The callback handler which will be invoked when the interrupt fires </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">callback_arg</td><td>Generic argument that will be provided to the callback when called </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga6d53ecb445603a2470ec1fd7e456bba3" name="ga6d53ecb445603a2470ec1fd7e456bba3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6d53ecb445603a2470ec1fd7e456bba3">&#9670;&nbsp;</a></span>cyhal_spi_enable_event()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cyhal_spi_enable_event </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__spi.html#gae8f0cf0233d0225a80815f8282d87b85">cyhal_spi_event_t</a>&#160;</td>
          <td class="paramname"><em>event</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>intr_priority</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>enable</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Configure SPI interrupt. </p>
<p >This function is used for word-approach</p>
<p >When an enabled event occurs, the function specified by <a class="el" href="group__group__hal__spi.html#ga5efa8d542f1ab5307d7896a249581a6a">cyhal_spi_register_callback</a> will be called.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">event</td><td>The SPI event type </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">intr_priority</td><td>The priority for NVIC interrupt events </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">enable</td><td>True to turn on interrupts, False to turn off </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gaa8f39b8e84c0925cb2f3ea44668de63b" name="gaa8f39b8e84c0925cb2f3ea44668de63b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa8f39b8e84c0925cb2f3ea44668de63b">&#9670;&nbsp;</a></span>cyhal_spi_set_fifo_level()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_set_fifo_level </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__spi.html#gab265880a2da90f74b0452a837e154e0a">cyhal_spi_fifo_type_t</a>&#160;</td>
          <td class="paramname"><em>type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>level</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Sets a threshold level for a FIFO that will generate an interrupt and a trigger output. </p>
<p >The RX FIFO interrupt and trigger will be activated when the receive FIFO has more entries than the threshold. The TX FIFO interrupt and trigger will be activated when the transmit FIFO has less entries than the threshold.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">type</td><td>FIFO type to set level for </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">level</td><td>Level threshold to set </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the level set </dd></dl>

</div>
</div>
<a id="ga98fbe6cea252e705ea4bd219376cc8a1" name="ga98fbe6cea252e705ea4bd219376cc8a1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga98fbe6cea252e705ea4bd219376cc8a1">&#9670;&nbsp;</a></span>cyhal_spi_enable_output()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_enable_output </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__spi.html#ga1cfefbde3bbc587e57f79e45558ae614">cyhal_spi_output_t</a>&#160;</td>
          <td class="paramname"><em>output</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__triggers__psoc6__01.html#ga96236d1368f920d28af90262e8b57046">cyhal_source_t</a> *&#160;</td>
          <td class="paramname"><em>source</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Enables the specified output signal from an SPI. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">output</td><td>Which output signal to enable </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">source</td><td>Pointer to user-allocated source signal object which will be initialized by enable_output. <code>source</code> should be passed to (dis)connect_digital functions to (dis)connect the associated endpoints. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the output enable </dd></dl>

</div>
</div>
<a id="gae7dae4894227e55b9315d75737fa3e24" name="gae7dae4894227e55b9315d75737fa3e24"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae7dae4894227e55b9315d75737fa3e24">&#9670;&nbsp;</a></span>cyhal_spi_disable_output()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_disable_output </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__spi.html#ga1cfefbde3bbc587e57f79e45558ae614">cyhal_spi_output_t</a>&#160;</td>
          <td class="paramname"><em>output</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Disables the specified output signal from an SPI. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">output</td><td>Which output signal to disable </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the output disable </dd></dl>

</div>
</div>
<a id="ga325d0890195400a2d1e4e994cd24fa09" name="ga325d0890195400a2d1e4e994cd24fa09"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga325d0890195400a2d1e4e994cd24fa09">&#9670;&nbsp;</a></span>cyhal_spi_init_cfg()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_init_cfg </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__configurator__t">cyhal_spi_configurator_t</a> *&#160;</td>
          <td class="paramname"><em>cfg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize the SPI peripheral using a configurator generated configuration struct. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI peripheral to configure </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">cfg</td><td>Configuration structure generated by a configurator. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the operation </dd></dl>

</div>
</div>
<a id="ga561c87eefd7d265448e646cc2f1c1ae3" name="ga561c87eefd7d265448e646cc2f1c1ae3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga561c87eefd7d265448e646cc2f1c1ae3">&#9670;&nbsp;</a></span>cyhal_spi_clear()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_spi_clear </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__spi__t">cyhal_spi_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Clear the SPI buffers. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The SPI object </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the clear request </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>Hardware Abstraction Layer (HAL)</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
